/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer 56 - I. 数组中数字出现的次数
 * @author: WXY
 * @create: 2022-12-10 20:40
 * @Version 1.0
 **/


public class Num056_1_singleNumbers {
    public static int[] singleNumbers(int[] nums) {
        int cur = 0;
        for (int num : nums) {
            cur = cur ^ num;
        }
        int last_1 = cur & (~cur + 1);
        int num1 = 0;
        int num2 = 0;
        for (int num : nums) {
            if ((num & last_1) == 0) {
                num1 = num1 ^ num;
            }
        }
        num2 = cur ^ num1;
        return new int[]{num1, num2};
    }

    public static void main(String[] args) {
        int[] arr = {1, 1, 1, 1, 4, 3};
        int[] ints = singleNumbers(arr);
        for (int i : ints) {
            System.out.println(i);
        }
    }
}
